#include"DList.h"

void test1()
{
	DListNode* head = DListInit();
	//DListPushBack(head, 1);
	//DListPushBack(head, 2);
	//DListPushBack(head, 3);
	//DListPushBack(head, 4);
	//DListPrint(head);
	///*DListNodePopBack(head);
	/*DListPrint(head);
	DListNodePopBack(head);
	DListPrint(head);
	DListNodePopBack(head); 
	DListPrint(head);
	DListNodePopBack(head);
	DListPrint(head);
	DListNodePopBack(head);*/
	DListPushFront(head, 1);
	DListPushFront(head, 2);
	DListPushFront(head, 3);
	DListPushFront(head, 4);
	DListPushFront(head, 5);
	DListPushFront(head, 6);
	printf("%d\n", DListSize(head));
	DListPopFront(head);
	DListPrint(head);
	DListPopFront(head);
	DListPrint(head);
	DListPopFront(head);
	DListPrint(head);
	DListPopFront(head);
	DListPrint(head);
	DListPopFront(head);
	printf("%d\n", DListSize(head));
	DListPrint(head);
	DListPopFront(head);
	printf("%d\n", DListSize(head));
	DListPrint(head);
	DListDestroy(head);
	head = NULL;
}


typedef struct ListNode {
	int val;
	struct ListNode *next;
}ListNode;
//	ListNode(int x) : val(x), next(NULL) {}

ListNode* partition(ListNode* pHead, int x) 
{
	// write code here
	ListNode* prev = NULL;
	ListNode* cur = pHead;
	ListNode* bhead = NULL;
	while (cur != NULL)
	{
		if (cur->val > x)
		{
			ListNode* tmp = cur->next;
			cur->next = bhead;
			bhead = cur;
			cur = tmp;
			if (prev)
			{
				prev->next = cur;
			}
			else
			{
				prev = cur;
			}
		}
		else
		{
			prev = cur;
			cur = cur->next;
		}
	}

}

int main()
{
	test1();
	return 0;
}
